#! /bin/sh
# this script is generated by the configure-script
prefix="/gg"
datadir="${prefix}/share"
NCURSES_OSPEED="short"
TERMINFO="/gg/share/terminfo"
MKDIRS="sh /Work/Prog/Source/ncurses-5.3/mkinstalldirs"
INSTALL="/bin/install -c"
INSTALL_DATA="${INSTALL} -m 644"
transform="s,x,x,"

TMP=${TMPDIR-/tmp}/man$$
trap "rm -f $TMP" 0 1 2 5 15

verb=$1
shift

mandir=$1
shift

srcdir=$1
shift

for i in $* ; do
case $i in #(vi
*.orig|*.rej) ;; #(vi
*.[0-9]*)
	section=`expr "$i" : '.*\.\([0-9]\)[xm]*'`;
	if test $verb = installing ; then
	if test ! -d $mandir/man${section} ; then
		$MKDIRS $mandir/man$section
	fi
	fi
	aliases=
	source=`basename $i`
	inalias=$source
	test ! -f $inalias && inalias="$srcdir/$inalias"
	if test ! -f $inalias ; then
		echo .. skipped $source
		continue
	fi
	aliases=`sed -f $srcdir/manlinks.sed $inalias | sort -u`
	# perform program transformations for section 1 man pages
	if test $section = 1 ; then
		target=$mandir/man${section}/`echo $source|sed "${transform}"`
	else
		target=$mandir/man${section}/$source
	fi
	prog_captoinfo=`echo captoinfo|sed "${transform}"`
	prog_clear=`echo clear|sed "${transform}"`
	prog_infocmp=`echo infocmp|sed "${transform}"`
	prog_infotocap=`echo infotocap|sed "${transform}"`
	prog_tic=`echo tic|sed "${transform}"`
	prog_toe=`echo toe|sed "${transform}"`
	prog_tput=`echo tput|sed "${transform}"`
	sed	-e "s,@DATADIR@,$datadir," \
		-e "s,@TERMINFO@,$TERMINFO," \
		-e "s,@NCURSES_OSPEED@,$NCURSES_OSPEED," \
		-e "s,@CAPTOINFO@,$prog_captoinfo," \
		-e "s,@CLEAR@,$prog_clear," \
		-e "s,@INFOCMP@,$prog_infocmp," \
		-e "s,@INFOTOCAP@,$prog_infotocap," \
		-e "s,@TIC@,$prog_tic," \
		-e "s,@TOE@,$prog_toe," \
		-e "s,@TPUT@,$prog_tput," \
		< $i >$TMP
	if test $verb = installing ; then
	if ( gzip -f $TMP )
	then
		mv $TMP.gz $TMP
	fi
	fi
	target="$target.gz"
	suffix=`basename $target | sed -e 's/^[^.]*//'`
	if test $verb = installing ; then
		echo $verb $target
		$INSTALL_DATA $TMP $target
		test -n "$aliases" && (
			cd $mandir/man${section} && (
				target=`basename $target`
				for cf_alias in $aliases
				do
					if test $section = 1 ; then
						cf_alias=`echo $cf_alias|sed "${transform}"`
					fi

					if test -f $cf_alias${suffix} ; then
						if ( cmp -s $target $cf_alias${suffix} )
						then
							:
						else
							echo .. $verb alias $cf_alias${suffix}
							rm -f $cf_alias${suffix}
							ln -s $target $cf_alias${suffix}
						fi
					else
						echo .. $verb alias $cf_alias${suffix}
						rm -f $cf_alias${suffix}
						ln -s $target $cf_alias${suffix}
					fi
				done
			)
		)
	elif test $verb = removing ; then
		echo $verb $target
		rm -f $target
		test -n "$aliases" && (
			cd $mandir/man${section} && (
				for cf_alias in $aliases
				do
					if test $section = 1 ; then
						cf_alias=`echo $cf_alias|sed "${transform}"`
					fi

					echo .. $verb alias $cf_alias${suffix}
					rm -f $cf_alias${suffix}
				done
			)
		)
	else
#		echo ".hy 0"
		cat $TMP
	fi
	;;
esac
done
exit 0
